/**
 * related to productCell.ui
 * 
 * @Author : chenglm
 * @Timestamp : 2016-12-28
 */
var root=ui("$");
var page = sm("do_Page");
var nf = sm("do_Notification");
var openHelper = require("helper/open");
var qqmath = require("util/qqmath");
var do_ALayout_left = ui("do_ALayout_left");
var do_ALayout_right = ui("do_ALayout_right");
var aLayout_imgLeft = ui("aLayout_imgLeft");
var aLayout_imgRight = ui("aLayout_imgRight");
var price1 = ui("price1");
var price2 = ui("price2");
var name1 = ui("name1");
var name2 = ui("name2");
var aLayout_addCart1 = ui("aLayout_addCart1");
var aLayout_addCart2 = ui("aLayout_addCart2");
var img1 = ui("img1");
var img2 = ui("img2");
//设置数据绑定的映射关系
root.setMapping({
	"img1.source":"r1.firstImg",
	"name1.text":"r1.name",
	"do_ALayout_left.tag" :"r1.id",
	"price1.tag" :"r1.price",
	"unit1.text":"r1.unit",
	
	"do_ALayout_right.visible": "rv",
	"img2.source":"r2.firstImg",
	"name2.text":"r2.name",
	"do_ALayout_right.tag" :"r2.id",
	"price2.tag" :"r2.price",
	"unit2.text":"r2.unit",
});

root.on("dataRefreshed", function(){
	price1.text = qqmath.getDight(price1.tag,2)+"";
	if (do_ALayout_right.visible) {
		price2.text = qqmath.getDight(price2.tag,2)+"";
	}
});

aLayout_imgLeft.on("touch","",300, function(data) {
	openHelper.open("source://view/mall/product/main.ui",{"id":do_ALayout_left.tag,"fromPage":"qshop"});
});

aLayout_imgRight.on("touch","",300, function(data) {
	openHelper.open("source://view/mall/product/main.ui",{"id":do_ALayout_right.tag,"fromPage":"qshop"});
});

aLayout_addCart1.on("touch","",300, function(data) {
	page.fire("ShopAddToCart", {productId:do_ALayout_left.tag,price:price1.tag,"imgJoin":img1.source,"x":120});
});
aLayout_addCart2.on("touch","",300, function(data) {
	page.fire("ShopAddToCart", {productId:do_ALayout_right.tag,price:price2.tag,"imgJoin":img2.source,"x":440});
});
